package ControlLayer;

import java.util.Calendar;
import java.sql.Date;

import DBLayer.DBOpening;
import DBLayer.IFDBOpening;
import ModelLayer.Opening;

public class OpeningCtr 
{
	private IFDBOpening openDb;
	
	public OpeningCtr()
	{
		openDb = new DBOpening();
	}

	public Opening getOpeningByDate(Date date)
	{
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		
		int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
		
		String day = "";
		
		switch(dayOfWeek)
		{
			case 1: day = "sunday";
			break;
			case 2: day = "monday";
			break;
			case 3: day = "tuesday";
			break;
			case 4: day = "wednesday";
			break;
			case 5: day = "thursday";
			break;
			case 6: day = "friday";
			break;
			case 7: day = "saturday";
			break;
		}
		
		return openDb.getOpeningByDay(day);
	}
}
